package com.heima.user.controller;

import cn.hutool.core.util.StrUtil;
import com.heima.models.common.Result;
import com.heima.models.users.Users;
import com.heima.user.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author itheima
 * @since 2023-07-06
 */
@RestController
@RequestMapping("/users")
public class UsersController {

    @Autowired
    private UsersService usersService;

    @GetMapping
    public Result getUserListByIdList(@RequestParam String ids) {
        if(StrUtil.isBlank(ids)) {
            return Result.error("参数不能为空");
        }

        String[] split = ids.split(",");
        List<String> idList = Arrays.asList(split);

        return usersService.getUsersByIdList(idList);
    }

}
